package com.ws.client.other;

import com.ws.client.BaseWebsocketClient;
import com.ws.client.utils.LogHelper;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.concurrent.ConcurrentHashMap;

public class InputSave {
    public static ConcurrentHashMap<String, WinClientBean> chromeDriverConcurrentHashMap = new ConcurrentHashMap<>();
    public static BaseWebsocketClient baseWebsocketClient;
    /**
     * socket远程地址
     */
    public static String remoteHost = "";
    /**
     * socket远程地址
     */
    public static String httpHost = "";

    public static String token_computer = "";
    /**
     * 驱动路径
     */
    public static String driver_path = "";
    /**
     * socket连接等待
     */
    public static int socket_time = 9;
    /**
     * 等待时间
     */
    public static int wait_time = 30;
    /**
     * 换成目录
     */
    public static String cache_path = "";
    //客户端编号
    public static int clientId = 0;

    /**
     * 关闭客户端窗口
     * @param uuid
     */
    public static void closeWin(String uuid) {
        try {
            if (chromeDriverConcurrentHashMap.containsKey(uuid)) {
                ChromeDriver driver = chromeDriverConcurrentHashMap.get(uuid).getChromeDriver();
                chromeDriverConcurrentHashMap.remove(uuid);
                try {
                    driver.close(); // 关闭当前浏览器窗口
                }catch (Exception e){

                }
                driver.quit();  // 退出驱动程序
                LogHelper.debug(uuid + "|closeWin 关闭完成");
            } else {
                LogHelper.debug(uuid + "|closeWin uuid不存在，无需关闭");
            }
        }catch (Exception e){
            e.printStackTrace();
            LogHelper.debug(uuid + "|closeWin关闭异常:" + e.getMessage());
        }

    }
}
